<script>
import Vue from 'vue';
import { mapMutations, mapActions, mapState } from 'vuex';
import Wechat from './common/wechat';
import store from '@/common/store';

export default {
	methods: {
		//应用初始化,获取模板,获取页面路由,获取用户信息,保存用户Token并返回初始进入页面
		...mapActions(['getAppInit', 'getTemplate', 'getRoutes', 'getUserInfo', 'setTokenAndBack']),
		// 获取系统栏高度
		async setAppInfo() {
			let that = this;
			let platform = '';
			return new Promise((resolve, reject) => {
				uni.getSystemInfo({
					success: function(e) {
						Vue.prototype.StatusBar = e.statusBarHeight;
						platform = 'wxMiniProgram';
						let custom = wx.getMenuButtonBoundingClientRect();
						Vue.prototype.Custom = custom;
						Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
						uni.setStorageSync('platform', platform);
						resolve(platform);
					}
				});
			});
		}
	},
	onLaunch: async function(options) {
		if (options.scene !== 1154) {
			Wechat.checkMiniProgramUpdate();
		}
		await this.setAppInfo();
		await this.getTemplate(options);
		let init = await this.getAppInit(options);
		if (process.env.NODE_ENV === 'development') {
			await this.getRoutes();
		}
	},
	onShow: function() {
		if (uni.getStorageSync('userInfo')) {
			this.$store.commit('CART_NUM');
			this.$store.dispatch('getCartList');
		}
	},
	onHide: function() {}
};
</script>

<style lang="scss">
@import 'static/colorui/main.css';
@import 'static/colorui/icon.css';
@import 'static/font/t-icon.css';
@import 'uview-ui/index.scss';

// 其他scss集成在uni.scss,(变量,class,minix)

uni-radio:not([disabled]) .uni-radio-input:hover,
uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
	border-color: #ccc !important;
}

page {
	-webkit-overflow-scrolling: touch; //ios滑动不流畅
	height: 100%;
	background: $u-bg-color;
	width: 100%;
	font-size: 30rpx;
	font-family: system-ui, -apple-system, BlinkMacSystemFont, segoe ui, Roboto, Helvetica, Arial, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol;
	word-break: break-all; //英文文本不换行
	color: #333;
}
::-webkit-scrollbar {
	width: 0;
	height: 0;
	color: transparent;
	display: none;
}
</style>
